package com.chenfan.process.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chenfan.process.common.constants.CommonFieldConstants;
import com.chenfan.process.common.utils.QueryWrapperUtils;
import com.chenfan.process.entity.po.ProcessFormAttribute;
import com.chenfan.process.repository.ProcessFormAttributeRepository;
import com.chenfan.process.service.ProcessFormAttributeService;

/**
 * @author liuming
 * @date 2021/11/24
 */
@Service
public class ProcessFormAttributeServiceImpl extends ServiceImpl<ProcessFormAttributeRepository, ProcessFormAttribute>
    implements ProcessFormAttributeService {

    @Override
    public List<ProcessFormAttribute> listByFormId(Long formId) {
        QueryWrapper<ProcessFormAttribute> queryWrapper = QueryWrapperUtils.newQueryWrapper();
        queryWrapper.eq(ProcessFormAttribute.Constants.FORM_ID, formId);
        return this.list(queryWrapper);
    }

    @Override
    public List<ProcessFormAttribute> listByFormIdAndAttribute(Long formId, List<Long> formAttributeIdList) {
        QueryWrapper<ProcessFormAttribute> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(ProcessFormAttribute.Constants.FORM_ID, formId);
        queryWrapper.in(CommonFieldConstants.ID, formAttributeIdList);
        return this.list(queryWrapper);
    }
}
